﻿
using Microsoft.Security.Application;


namespace ElectronicCommerce.Framework.Utility
{
    /// <summary>
    /// Anti Xss Encoder two
    /// </summary>
    public static class AntiXssEncoderTwo
    {
        public static string HtmlAttributeEncode(object s)
        {
            if (s == null)
            {
                return "";
            }
            return HtmlAttributeEncode(s.ToString());
        }

        public static string HtmlAttributeEncode(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            return Encoder.HtmlAttributeEncode(s);
        }

        public static string HtmlEncode(object s)
        {
            if (s == null)
            {
                return "";
            }
            return HtmlEncode(s.ToString());
        }

        public static string HtmlEncode(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            return Encoder.HtmlEncode(s);
        }

        public static string JavaScriptEncode(object s)
        {
            if (s == null)
            {
                return "";
            }
            return JavaScriptEncode(s.ToString());
        }

        public static string JavaScriptEncode(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            return Encoder.JavaScriptEncode(s);
        }

        public static string UrlEncode(object s)
        {
            if (s == null)
            {
                return "";
            }
            return UrlEncode(s.ToString());
        }

        public static string UrlEncode(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            return Encoder.UrlEncode(s);
        }

        public static string VisualBasicScriptEncode(object s)
        {
            if (s == null)
            {
                return "";
            }
            return VisualBasicScriptEncode(s.ToString());
        }

        public static string VisualBasicScriptEncode(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            return Encoder.VisualBasicScriptEncode(s);
        }

        public static string XmlAttributeEncode(object s)
        {
            if (s == null)
            {
                return "";
            }
            return XmlAttributeEncode(s.ToString());
        }

        public static string XmlAttributeEncode(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            return Encoder.XmlAttributeEncode(s);
        }


        public static string XmlEncode(object s)
        {
            if (s == null)
            {
                return "";
            }
            return XmlEncode(s.ToString());
        }

        public static string XmlEncode(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return string.Empty;
            }
            return Encoder.XmlEncode(s);
        }
    }
}
